package io.renren.modules.gasstation.gasstationenterprise.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.modules.gasstation.gasstationenterprise.dao.GasStationEnterpriseDAO;
import io.renren.modules.gasstation.gasstationenterprise.entity.GasStationEnterpriseEntity;
import io.renren.modules.gasstation.gasstationenterprise.service.GasStationEnterpriseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;

/**
 * @Author：T-weiwei
 * @Description: 加油站企业业务实现层
 * @Email：tweiwei@aliyun.com
 * @CreateDate：2022-01-10-下午3:40
 * @CopyRight：http://www.huaxun.ink/
 * @Hint： This content is limited to the internal circulation of HuaXun Hi Tech Co., Ltd.,
 * and is forbidden to be leaked and used for other commercial purposes
 **/
@Service("gasStationEnterpriseService")
public class GasStationEnterpriseServiceImpl extends ServiceImpl<GasStationEnterpriseDAO, GasStationEnterpriseEntity>
        implements GasStationEnterpriseService {

    /**
     * 加油站企业数据层
     */
    @Resource
    private GasStationEnterpriseDAO enterpriseDAO;

    /**
     * 重写update方法
     * @param enterpriseEntity 加油站企业实体类
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(GasStationEnterpriseEntity enterpriseEntity) {
        super.updateById(enterpriseEntity);
    }

    /**
     * 根据社会信用代码获取该企业是否存在
     * @param enterpriseCode 社会信用代码
     * @return 是否成功
     */
    @Override
    public Boolean isExistEnterpriseByEnterpriseCode(String enterpriseCode) {
        Integer isExist = this.enterpriseDAO.isExistEnterpriseByEnterpriseCode(enterpriseCode);
        if (isExist != null) {
            return true;
        } else {
            return false;
        }
    }

}
